import { NodeRoot } from "../Base/NodeRoot";
import { NMNode } from "../Base/NodeGraph";
@NMNode
export class CameraFollow extends NodeRoot{
    public FollowNode: cc.Node;
    public CameraNode:cc.Node;
    public Follow:boolean;
    public Offset;
    private setNode:cc.Node;
    private setCamera:cc.Node;

    private offset:cc.Vec2;
    public isComplete=false;
    onEnter(){
        this.Follow=false;
        this.setNode=this.FollowNode;
        if(!this.setNode){
            this.setNode=this.ownerNode;
        }
        this.setCamera=this.CameraNode;
        this.offset=cc.v2(this.Offset.x,this.Offset.y);
    }
    onStep(dt:number){
        return this.Follow;
    }
    onLateUpdate(){
        this.setCamera.position=(this.setNode.position.add(this.offset));
    }
}